home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************\
- |***************************************************************************|
- | |
- | File Name: Offscreen.c |
- | |
- | Contains: Implementation of _Offscreen GWorld buffers |
- | |
- | Written by: GeoWar |
- | |
- | Copyright: © 1995 by Apple Computer,Inc.,all rights reserved. |
- | |
- | **************************************************************************|
- | C h a n g e H i s t o r y (most recent first): |
- | **************************************************************************|
- | Vers Date Author Description |
- | ---- -------- ------ ----------------------------------------|
- | 2.14 05/03/00 GAW Carbonized! |
- | 2.13 03/17/00 GAW Changed code to actuall use pixelDepth! |
- | 2.12 12/15/99 GAW Added Get/Set default NewGWorld flags |
- | 2.11 6/16/99 GAW GlobalToLocal when !gDefaultPixelDepth |
- | 2.10 6/16/99 GAW SetPort_offscreen now returns pixmap |
- | 2.9 5/30/99 GAW Bug fix - nil maskRgnHdl on open |
- | 2.8 12/16/98 GAW Added Get/Set Pixel Depth |
- | 2.7 12/16/98 GAW Added Get/Set Default CopyBit mask |
- | 2.6 12/3/98 GAW moved saved port/device info to struct |
- | 2.5 9/25/98 GAW Added more parameter validity checking |
- | 2.4 9/25/98 GAW Added Text Font/Size support |
- | 2.3 9/25/98 GAW Added Use count pixel locking/unlocking |
- | 2.2 9/19/97 GAW Added Get/Set Default Pixel Depth |
- | 2.1 5/24/95 GAW First public version |
- | 0.0 5/18/95 GAW Initial version |
- |***************************************************************************|
- \***************************************************************************/
-
- #pragma segment _Offscreen
-
- /**\
- |**| Includes
- \**/
-
- #include <Memory.h>
- #include "Offscreen.h"
-
- /**\
- |**| Local (static) Globals
- \**/
-
- static SInt16 gDefaultPixelDepth = 0;
- static GWorldFlags gDefaultGWorldFlags = 0;
-
- /**\
- |**| Local Function Prototypes
- \**/
-
- /**\
- |**| Global Functions
- \**/
-
- /*
- ##############################################################################
- # Prototype: Window_OffscreenPtr Open_Offscreen(WindowPtr pWindowPtr)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: Opens _Offscreen buffer & copies window to it.
- # Parameters: pWindowPtr - WindowPtr of the window we want to buffer.
- # Returns: Pointer to _Offscreen parameters
- # Examples: myWindow_OffscreenPtr = Open_Offscreen(myWindowPtr);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.14 5/03/00 GAW Carbonized!
- # 2.1 8/07/95 GAW Changed to Open_OffscreenBuffer call.
- # 0.0 5/24/95 GAW Initial version
- # ****************************************************************************
- */
- Window_OffscreenPtr Open_Offscreen(WindowPtr pWindowPtr)
- {
- Window_OffscreenPtr the_Offscreen;
- Rect globalRect;
-
- #if TARGET_API_MAC_CARBON // <2.14>
- SetPortWindowPort(pWindowPtr);
- GetWindowBounds(pWindowPtr,kWindowGlobalPortRgn,&globalRect);
- #else
- SetPort((GrafPtr) pWindowPtr);
- globalRect = pWindowPtr->portRect;
- LocalToGlobal((Point *) &globalRect.top);
- LocalToGlobal((Point *) &globalRect.bottom);
- #endif TARGET_API_MAC_CARBON
-
- the_Offscreen = Open_OffscreenBuffer(pWindowPtr, &globalRect);
-
- if (the_Offscreen)
- Copy_Offscreen(the_Offscreen);
-
- return the_Offscreen;
- }
-
- /*
- ##############################################################################
- # Prototype:
- # Window_OffscreenPtr Open_OffscreenBuffer(
- # WindowPtr pWindowPtr, const Rect* pRect)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: Opens _Offscreen buffer & copies window to it.
- # Parameters: pWindowPtr - WindowPtr of the window we want to buffer.
- # pRect - (global) Rectangle of the area we want to buffer
- # Returns: Pointer to _Offscreen parameters
- # Examples: myWindow_OffscreenPtr = Open_OffscreenBuffer(myWindowPtr,&myRect);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.14 5/03/00 GAW Carbonized!
- # 2.13 03/17/00 GAW Changed code to actuall use pixelDepth!
- # 2.11 6/16/99 GAW GlobalToLocal when (0 == gDefaultPixelDepth)
- # 2.9 5/30/99 GAW Bug fix - nil maskRgnHdl on open
- # 2.6 12/3/98 GAW moved saved port/device info to struct
- # 2.4 9/25/98 GAW Added Text Font/Size support
- # 2.3 9/25/98 GAW Added Use count pixel locking/unlocking
- # 2.2 3/23/96 GAW added myErr for error debugging
- # 2.1 8/07/95 GAW Initial version
- # ****************************************************************************
- */
-
- Window_OffscreenPtr Open_OffscreenBuffer(WindowPtr pWindowPtr,const Rect* pRect)
- {
- Rect tRect;
- Window_OffscreenPtr the_Offscreen;
- GWorldPtr theWorld;
- OSErr myErr;
-
- if (pRect == nil) // param error
- return nil;
-
- tRect = *pRect;
-
- if (!(the_Offscreen = (Window_OffscreenPtr) NewPtr(sizeof(Window_Offscreen))))
- return nil;
-
- #if TARGET_API_MAC_CARBON // <2.14>
- SetPortWindowPort(pWindowPtr);
- #else
- SetPort((GrafPtr) pWindowPtr);
- #endif TARGET_API_MAC_CARBON
-
- GetGWorld(&the_Offscreen->windowPort, &the_Offscreen->windowDevice);
-
- the_Offscreen->pixelDepth = gDefaultPixelDepth; // <2.13>
-
- if (the_Offscreen->pixelDepth)
- myErr = NewGWorld(&theWorld, the_Offscreen->pixelDepth,
- &tRect, 0L, the_Offscreen->windowDevice, 0);
- else
- {
- GlobalToLocal((Point*) &tRect.top); // <2.11>
- GlobalToLocal((Point*) &tRect.bottom); // <2.11>
-
- myErr = NewGWorld(&theWorld, 0,
- &tRect, 0L, the_Offscreen->windowDevice, noNewDevice);
- }
-
- if (myErr == noErr)
- {
- the_Offscreen->offscreenWorld = theWorld;
- the_Offscreen->offscreenDevice =
- GetGWorldDevice(the_Offscreen->offscreenWorld);
-
- the_Offscreen->pixelslockedCount = 0; // zero pixel lock use count
- the_Offscreen->maskRgnHdl = nil; // <2.7>
-
- if (SetPort_Offscreen(the_Offscreen) == nil) // if we can't lock it...
- {
- DisposeGWorld(theWorld);
- DisposePtr((Ptr)the_Offscreen);
- return nil;
- }
-
- SetOrigin(tRect.left, tRect.top);
- #if !OPAQUE_TOOLBOX_STRUCTS // <2.14>
- TextFont(pWindowPtr->txFont);
- TextSize(pWindowPtr->txSize);
- #endif !OPAQUE_TOOLBOX_STRUCTS
-
- EraseRect(&tRect);
- Restore_Port(the_Offscreen);
- return (the_Offscreen);
- }
- else
- {
- DisposePtr((Ptr)the_Offscreen);
- return nil;
- }
- }
-
- /*
- ##############################################################################
- # Prototype: void Copy_Offscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: copies window to _Offscreen buffer.
- # Parameters: pWindow_OffscreenPtr - Pointer to _Offscreen parameters
- # Returns: none
- # Examples: Copy_Offscreen(myWindow_OffscreenPtr);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.14 5/03/00 GAW Carbonized!
- # 2.5 9/25/98 GAW Added parameter validity checking
- # 2.1 8/07/95 GAW Changed to Copy_OffscreenBuffer call.
- # 0.0 5/24/95 GAW Initial version
- # ****************************************************************************
- */
- void Copy_Offscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr)
- {
- Rect srcRect,dstRect; // <2.14>
-
- #if TARGET_API_MAC_CARBON // <2.14>
- GetPortBounds(pWindow_OffscreenPtr->windowPort,&srcRect);
- GetPortBounds(pWindow_OffscreenPtr->offscreenWorld,&dstRect);
- #else
- srcRect = pWindow_OffscreenPtr->windowPort->portRect;
- dstRect = pWindow_OffscreenPtr->offscreenWorld->portRect;
- #endif TARGET_API_MAC_CARBON
-
- Copy_OffscreenBuffer(pWindow_OffscreenPtr,&srcRect,&dstRect);
- }
- }
-
- /*
- ##############################################################################
- # Prototype:
- # void Copy_OffscreenBuffer(
- # Window_OffscreenPtr pWindow_OffscreenPtr
- # const Rect* sRect, const Rect* dRect)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: copies window to _Offscreen buffer.
- # Parameters: pWindow_OffscreenPtr - Pointer to _Offscreen parameters
- # sRect - Source Rectangle (onscreen)
- # dRect - Destination Rectangle (offscreen)
- # Returns: none
- # Examples: Copy_Offscreen(myWindow_OffscreenPtr);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.14 5/03/00 GAW Carbonized!
- # 2.7 12/16/98 GAW Added Get/Set Default CopyBit mask
- # 2.6 12/3/98 GAW moved saved port/device info to struct
- # 2.1 8/07/95 GAW Initial version
- # ****************************************************************************
- */
- void Copy_OffscreenBuffer(Window_OffscreenPtr pWindow_OffscreenPtr,
- const Rect* sRect,
- const Rect* dRect)
- {
- PixMapHandle offScreenPixMapH;
-
- if (pWindow_OffscreenPtr)
- {
- offScreenPixMapH = SetPort_Offscreen(pWindow_OffscreenPtr);
- if (offScreenPixMapH)
- {
- ForeColor(blackColor); // Set the fore color to Black
- BackColor(whiteColor); // Set the back color to White
- #if TARGET_API_MAC_CARBON // <2.14>
- CopyBits( GetPortBitMapForCopyBits(pWindow_OffscreenPtr->windowPort), // <2.14>
- (BitMap *) *offScreenPixMapH, sRect, dRect, srcCopy,
- pWindow_OffscreenPtr->maskRgnHdl);
- #else
- CopyBits( (BitMap*) *pWindow_OffscreenPtr->windowPort->portPixMap,
- (BitMap*) *offScreenPixMapH, sRect, dRect, srcCopy,
- pWindow_OffscreenPtr->maskRgnHdl);
- #endif TARGET_API_MAC_CARBON
- Unlock_Offscreen(pWindow_OffscreenPtr);
- }
- Restore_Port(pWindow_OffscreenPtr);
- }
- }
-
- /*
- ##############################################################################
- # Prototype: void Copy_Onscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: copies _Offscreen buffer to screen.
- # Parameters: pWindow_OffscreenPtr - Pointer to _Offscreen parameters
- # Returns: none
- # Examples: Copy_Onscreen(myWindow_OffscreenPtr);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.14 5/03/00 GAW Carbonized!
- # 2.5 9/25/98 GAW Added parameter validity checking
- # 2.1 8/07/95 GAW Changed to Copy_OnscreenBuffer call.
- # 0.0 5/24/95 GAW Initial version
- # ****************************************************************************
- */
- void Copy_Onscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr)
- {
- Rect srcRect,dstRect;
- #if TARGET_API_MAC_CARBON // <2.14>
- GetPortBounds(pWindow_OffscreenPtr->offscreenWorld,&srcRect);
- GetPortBounds(pWindow_OffscreenPtr->windowPort,&dstRect);
- #else
- srcRect = pWindow_OffscreenPtr->offscreenWorld->portRect;
- dstRect = pWindow_OffscreenPtr->windowPort->portRect;
- #endif TARGET_API_MAC_CARBON
-
- Copy_OnscreenBuffer(pWindow_OffscreenPtr,&srcRect,&dstRect);
- }
- }
-
- /*
- ##############################################################################
- # Prototype:
- # void Copy_OnscreenBuffer(
- # Window_OffscreenPtr pWindow_OffscreenPtr
- # const Rect* sRect,const Rect* dRect)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: copies _Offscreen buffer to screen.
- # Parameters: pWindow_OffscreenPtr - Pointer to _Offscreen parameters
- # sRect - Source Rectangle (offscreen)
- # dRect - Destination Rectangle (onscreen)
- # Returns: none
- # Examples: Copy_Onscreen(myWindow_OffscreenPtr);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.7 12/16/98 GAW Added Get/Set Default CopyBit mask
- # 2.6 12/3/98 GAW moved saved port/device info to struct
- # 2.1 8/07/95 GAW Initial version
- # ****************************************************************************
- */
-
- void Copy_OnscreenBuffer(Window_OffscreenPtr pWindow_OffscreenPtr,
- const Rect* sRect,
- const Rect* dRect)
- {
- PixMapHandle offScreenPixMapH;
- PixMapHandle onScreenPixMapH;
-
- if (pWindow_OffscreenPtr)
- {
- SetPort_Onscreen(pWindow_OffscreenPtr);
- offScreenPixMapH = Lock_Offscreen(pWindow_OffscreenPtr);
- #if ACCESSOR_CALLS_ARE_FUNCTIONS // <2.14>
- onScreenPixMapH = GetPortPixMap(pWindow_OffscreenPtr->windowPort);
- #else
- onScreenPixMapH = pWindow_OffscreenPtr->windowPort->portPixMap;
- #endif
-
- if (offScreenPixMapH && onScreenPixMapH)
- {
- Rect pixRect = (*offScreenPixMapH)->bounds;
- Rect tRect = *sRect;
-
- OffsetRect(&tRect,pixRect.left,pixRect.top);
-
- ForeColor(blackColor); // Set the fore color to Black
- BackColor(whiteColor); // Set the back color to White
- #if 1
- if (GETPIXMAPPIXELFORMAT(*onScreenPixMapH) == GETPIXMAPPIXELFORMAT(*offScreenPixMapH))
- #else
- if ( (*offScreenPixMapH)->pixelType ==
- (*(pWindow_OffscreenPtr->windowPort->portPixMap))->pixelType)
- #endif 1
- {
- long seed = (*(*onScreenPixMapH)->pmTable)->ctSeed;
- (*((*offScreenPixMapH)->pmTable))->ctSeed = seed;
- }
-
- CopyBits((BitMap *) *offScreenPixMapH,
- (BitMap *) *onScreenPixMapH,
- &tRect, dRect, srcCopy, pWindow_OffscreenPtr->maskRgnHdl);
- Unlock_Offscreen(pWindow_OffscreenPtr);
- }
- Restore_Port(pWindow_OffscreenPtr);
- }
- }
-
- /*
- ##############################################################################
- # Prototype: void Save_Port(void)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: save current CGrafPtr & GDHandle to _Offscreen globals.
- # Parameters: none
- # Returns: none
- # Examples: Save_Port();
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.6 12/3/98 GAW moved saved port/device info to struct
- # 0.0 5/24/95 GAW Initial version
- # ****************************************************************************
- */
- void Save_Port(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr)
- GetGWorld(
- &pWindow_OffscreenPtr->savedCGrafPtr,
- &pWindow_OffscreenPtr->savedGDHandle);
- }
-
- /*
- ##############################################################################
- # Prototype: void Restore_Port(void)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: restore CGrafPtr & GDHandle from _Offscreen globals
- # Parameters: none
- # Returns: none
- # Examples: Restore_Port();
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.6 12/3/98 GAW moved saved port/device info to struct
- # 0.0 5/24/95 GAW Initial version
- # ****************************************************************************
- */
- void Restore_Port(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr && pWindow_OffscreenPtr->savedCGrafPtr)
- SetGWorld(
- pWindow_OffscreenPtr->savedCGrafPtr,
- pWindow_OffscreenPtr->savedGDHandle);
- }
-
- /*
- ##############################################################################
- # Prototype: void Close_Offscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: Closes _Offscreen buffer
- # Parameters: pWindow_OffscreenPtr - Pointer to _Offscreen parameters
- # Returns: none
- # Examples: Close_Offscreen(myWindow_OffscreenPtr);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.5 9/25/98 GAW Added parameter validity checking
- # 0.0 5/24/95 GAW Initial version
- # ****************************************************************************
- */
- void Close_Offscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr->offscreenWorld)
- DisposeGWorld(pWindow_OffscreenPtr->offscreenWorld);
- if (pWindow_OffscreenPtr)
- DisposePtr((Ptr)pWindow_OffscreenPtr);
- // pWindow_OffscreenPtr = nil;
- }
- }
-
- /*
- ##############################################################################
- # Prototype: void SetPort_Onscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: Set port & device to _Onscreen after saving current values
- # Parameters: pWindow_OffscreenPtr - Pointer to _Offscreen parameters
- # Returns: none
- # Examples: SetPort_Onscreen(myWindow_OffscreenPtr);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.6 12/3/98 GAW moved saved port/device info to struct
- # 0.0 5/24/95 GAW Initial version
- # ****************************************************************************
- */
- void SetPort_Onscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr)
- {
- Save_Port(pWindow_OffscreenPtr);
- SetGWorld(pWindow_OffscreenPtr->windowPort,
- pWindow_OffscreenPtr->windowDevice);
- SetPort((GrafPtr) pWindow_OffscreenPtr->windowPort);
- }
- }
-
- /*
- ##############################################################################
- # Prototype: void SetPort_Offscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: Set port & device to _Offscreen after saving current values
- # Parameters: pWindow_OffscreenPtr - Pointer to _Offscreen parameters
- # Returns: none
- # Examples: Copy_Offscreen(myWindow_OffscreenPtr);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.10 6/16/99 GAW SetPort_offscreen now returns pixmap
- # 2.6 12/3/98 GAW moved saved port/device info to struct
- # 0.0 5/24/95 GAW Initial version
- # ****************************************************************************
- */
- PixMapHandle SetPort_Offscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr)
- {
- Save_Port(pWindow_OffscreenPtr);
- SetGWorld(pWindow_OffscreenPtr->offscreenWorld,
- pWindow_OffscreenPtr->offscreenDevice);
- return Lock_Offscreen(pWindow_OffscreenPtr); // <2.10>
- }
- return nil;
- }
-
- /*
- ##############################################################################
- # Prototype: PixMapHandle Lock_Offscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: Locks _Offscreen PixMap & returns its handle.
- # Parameters: pWindow_OffscreenPtr - Pointer to _Offscreen parameters
- # Returns: PixMapHandle
- # Examples: myPixMapHandle = Lock_Offscreen(myWindow_OffscreenPtr);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.5 9/25/98 GAW Added parameter validity checking
- # 2.3 9/25/98 GAW Added Use count pixel locking/unlocking
- # 0.0 5/24/95 GAW Initial version
- # ****************************************************************************
- */
- PixMapHandle Lock_Offscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr)
- {
- PixMapHandle offScreenPixMapH = GetGWorldPixMap(
- pWindow_OffscreenPtr->offscreenWorld);
- if (!pWindow_OffscreenPtr->pixelslockedCount) // if unlocked...
- {
- if (!LockPixels(offScreenPixMapH)) // if we can't lock...
- return nil;
- }
- pWindow_OffscreenPtr->pixelslockedCount++; // bump pixel lock use count
- return offScreenPixMapH;
- }
- else
- return nil;
- }
-
- /*
- ##############################################################################
- # Prototype: void Unlock_Offscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- #=============================================================================
- # Author: GeoWar Wednesday,May 24,1995
- # Description: unlocks _Offscreen pixmap handle
- # Parameters: pWindow_OffscreenPtr - Pointer to _Offscreen parameters
- # Returns: none
- # Examples: Unlock_Offscreen(myWindow_OffscreenPtr);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.5 9/25/98 GAW Added parameter validity checking
- # 2.3 9/25/98 GAW Added Use count pixel locking/unlocking
- # 0.0 5/24/95 GAW Initial version
- # ****************************************************************************
- */
- void Unlock_Offscreen(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr)
- {
- if (pWindow_OffscreenPtr->pixelslockedCount) // if locked...
- {
- pWindow_OffscreenPtr->pixelslockedCount--; // bump pixel lock use count
-
- if (!pWindow_OffscreenPtr->pixelslockedCount) // if lock count zero...
- UnlockPixels(GetGWorldPixMap(pWindow_OffscreenPtr->offscreenWorld));
- }
- }
- }
-
- /*
- ##############################################################################
- # Prototype: SInt16 Get_DefaultPixelDepth(void)
- # Prototype: SInt16 Set_DefaultPixelDepth(SInt16 pDefaultPixelDepth)
- #=============================================================================
- # Author: GeoWar Monday, Nov 4, 1996
- # Description: accessors for DefaultPixelDepth
- # Parameters: none & SInt16 pixel depth
- # Returns: SInt16 pixel depth & previous depth
- # Examples: x = Get_DefaultPixelDepth(); Set_DefaultPixelDepth(8);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.2 9/19/97 GAW Initial version
- # ****************************************************************************
- */
- SInt16 Get_DefaultPixelDepth(void)
- {
- return gDefaultPixelDepth;
- }
-
-
- SInt16 Set_DefaultPixelDepth(SInt16 pDefaultPixelDepth)
- {
- SInt16 result = gDefaultPixelDepth;
- gDefaultPixelDepth = pDefaultPixelDepth;
- return result;
- }
-
- /*
- ##############################################################################
- # Prototype: SInt16 Get_PixelDepth(Window_OffscreenPtr pWindow_OffscreenPtr)
- # Prototype: SInt16 Set_PixelDepth(
- # Window_OffscreenPtr pWindow_OffscreenPtr,SInt16 pPixelDepth)
- #=============================================================================
- # Author: GeoWar Monday, Nov 4, 1996
- # Description: accessors for PixelDepth
- # Parameters: none & SInt16 pixel depth
- # Returns: SInt16 pixel depth & previous depth
- # Examples: x = Get_PixelDepth(myWindow_OffscreenPtr);
- # Set_PixelDepth(myWindow_OffscreenPtr,8);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.8 12/16/98 GAW Initial version
- # ****************************************************************************
- */
- SInt16 Get_PixelDepth(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- return pWindow_OffscreenPtr->pixelDepth;
- }
-
-
- SInt16 Set_PixelDepth(Window_OffscreenPtr pWindow_OffscreenPtr,SInt16 pPixelDepth)
- {
- SInt16 result = pWindow_OffscreenPtr->pixelDepth;
- pWindow_OffscreenPtr->pixelDepth = pPixelDepth;
- return result;
- }
-
- /*
- ##############################################################################
- # Prototype: RgnHandle Get_MaskRegion(Window_OffscreenPtr pWindow_OffscreenPtr)
- # Prototype: RgnHandle Set_MaskRegion(
- # Window_OffscreenPtr pWindow_OffscreenPtr,
- # RgnHandle pDefaultMaskRegion)
- #=============================================================================
- # Author: GeoWar Monday, Nov 4, 1996
- # Description: accessors for gDefaultMaskRegion
- # Parameters: none & default mask (RgnHandle)
- # Returns: RgnHandle mask & previous mask
- # Examples: myRgn = Get_MaskRegion(myWindow_OffscreenPtr);
- # Set_MaskRegion(myWindow_OffscreenPtr,myRgn);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.7 12/16/98 GAW Initial version
- # ****************************************************************************
- */
- RgnHandle Get_MaskRegion(Window_OffscreenPtr pWindow_OffscreenPtr)
- {
- return pWindow_OffscreenPtr->maskRgnHdl;
- }
-
- RgnHandle Set_MaskRegion(
- Window_OffscreenPtr pWindow_OffscreenPtr,RgnHandle pNewMaskRegion)
- {
- RgnHandle result = pWindow_OffscreenPtr->maskRgnHdl;
- pWindow_OffscreenPtr->maskRgnHdl = pNewMaskRegion;
- return result;
- }
-
- /*
- ##############################################################################
- # Prototype: void Set_OnscreenWindow(
- # Window_OffscreenPtr pWindow_OffscreenPtr,
- # WindowPtr pWindowPtr)
- #=============================================================================
- # Author: GeoWar Monday, Nov 4, 1996
- # Description: change the onscreen windowPort & device
- # Parameters: the WindowPtr
- # Returns: none
- # Examples: Set_OnscreenWindow(myWindow_OffscreenPtr,FrontWindow());
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.14 5/03/00 GAW Carbonized!
- # 2.7 12/16/98 GAW Initial version
- # ****************************************************************************
- */
-
- void Set_OnscreenWindow(Window_OffscreenPtr pWindow_OffscreenPtr,WindowPtr pWindowPtr)
- {
- GrafPtr savePort;
-
- GetPort(&savePort);
- #if TARGET_API_MAC_CARBON // <2.14>
- SetPortWindowPort(pWindowPtr);
- #else
- SetPort((GrafPtr) pWindowPtr);
- #endif TARGET_API_MAC_CARBON
-
- GetGWorld(&pWindow_OffscreenPtr->windowPort, &pWindow_OffscreenPtr->windowDevice);
- SetPort(savePort);
- }
-
-
- /*
- ##############################################################################
- # Prototype: GWorldFlags Get_DefaultGWorldFlags(void)
- # Prototype: GWorldFlags Set_DefaultGWorldFlags(GWorldFlags pDefaultGWorldFlags)
- #=============================================================================
- # Author: GeoWar Monday, Nov 4, 1996
- # Description: accessors for DefaultGWorldFlags
- # Parameters: none & SInt16 pixel depth
- # Returns: SInt16 pixel depth & previous depth
- # Examples: x = Get_DefaultGWorldFlags(); Set_DefaultGWorldFlags(xxx);
- # Assumptions: None
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- # Vers Date Author Description
- # ---- -------- ------ ------------------------------------------
- # 2.12 12/15/99 GAW Added Get/Set default NewGWorld flags
- # ****************************************************************************
- */
- GWorldFlags Get_DefaultGWorldFlags(void)
- {
- return gDefaultGWorldFlags;
- }
-
-
- GWorldFlags Set_DefaultGWorldFlags(GWorldFlags pDefaultGWorldFlags)
- {
- SInt16 result = gDefaultGWorldFlags;
- gDefaultGWorldFlags = pDefaultGWorldFlags;
- return result;
- }
-